from django import forms

from web import models
from web.forms.bootstrapbase import BootStrapForm


class addWikiForm(BootStrapForm, forms.ModelForm):
    class Meta:
        model = models.Wiki
        exclude = ['project', 'deepth']

    def __init__(self, request, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.request = request
        wiki_data_list = [('', '请选择父目录'), ]
        _d = models.Wiki.objects.filter(project=request.login_user.project).values_list('id','title')
        wiki_data_list.extend(list(_d))
        self.fields['parent'].choices = wiki_data_list
